<template>
  <popup
    ref="popupRef"
    :title="qrcode.title+'二维码'"
    :width="'400px'"
    :cancelButtonText="false"
    :confirmButtonText="false"
    :async="true"
    @confirm="() => {}"
  >
      <el-image  :src="qrcode.qrcodeImgUrl"></el-image>
      <div>
        <span>
          链接地址：{{qrcode.qrcodeRedirectUrl}}
        </span>
        <div class="inline-block">
          <el-button type="text" @click="copy">复制</el-button>
        </div>
      </div>
  </popup>
</template>
<script lang="ts" setup>
import popup from '@/components/popup/index.vue'
import feedback from '@/utils/feedback'
const popupRef = ref<InstanceType<typeof popup>>()
const qrcode=ref({
  qrcodeRedirectUrl: '',
  qrcodeImgUrl: '',
  title: ''
})
function copy() {
  navigator.clipboard.writeText(qrcode.value.qrcodeRedirectUrl)
  feedback.msgSuccess('复制成功')
}
function open(){
  console.log('open')
  popupRef.value?.open()
}
function setQrcode(title:string,qrcodeRedirectUrl: string, qrcodeImgUrl: string) {
  qrcode.value.title = title
  qrcode.value.qrcodeRedirectUrl = qrcodeRedirectUrl
  qrcode.value.qrcodeImgUrl = qrcodeImgUrl
}
defineExpose({
  copy,
  setQrcode,
  open
})
</script>
